package com.ht.medicaltreatment.view

import android.app.Dialog
import android.content.Context
import android.view.LayoutInflater
import com.ht.medicaltreatment.R
import com.xgst.lib.utils.ScreenUtils
import kotlinx.android.synthetic.main.dialog_permission_set_layout.*

class PermissionSettingDialog @JvmOverloads constructor(context: Context) : Dialog(context,R.style.dialogStyle) {
    init {
        val view = LayoutInflater.from(context).inflate(R.layout.dialog_permission_set_layout,null,false)
        setContentView(view)

        //window设置要放在setContentView之后，不然没效果
        val attributes = window?.attributes
        attributes?.height = ScreenUtils.dp2px(context,150)
        attributes?.width = ScreenUtils.dp2px(context,251)
        window?.attributes = attributes
        setCancelable(false)
        //设置0之后，没有灰色背景了
        //window.setDimAmount(0f)
    }

    fun show(positive:()->Unit){
        tvNegative.setOnClickListener {
            hide()
        }
        tvPositive.setOnClickListener {
            positive()
            hide()
        }
    }

}
